export default {
  /**设置localStorage的值
   *
   * @param key 参数名称
   * @param value
   */
  set(key: string, value: any) {
    localStorage.setItem(key, JSON.stringify(value))
  },
  /**获取localStorage的值
   *
   * @param key
   */
  get(key: string) {
    const value = localStorage.getItem(key)
    if (!value) return ''
    try {
      return JSON.parse(value)
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
    } catch (error) {
      return value
    }
  },
  /**清除localStorage的某一值
   *
   * @param key
   */
  remove(key: string) {
    localStorage.removeItem(key)
  },
  /**
   * 清除localStorage的所有值
   */
  clear() {
    localStorage.clear()
  }
}
